package com.stud.seckill.controller;

import com.stud.seckill.common.auth.UserContext;
import com.stud.seckill.entity.UserEntity;
import com.stud.seckill.service.UserService;
import com.stud.seckill.common.vo.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Libra
 * @since 2024-03-29
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("新增")
    @PostMapping("/add")
    public String add(@RequestBody UserEntity user) {
        userService.add(user);
        return "OK";
    }

    @ApiOperation("当前登录信息")
    @GetMapping("/info")
    public R info() {
        return R.success(UserContext.getUser());
    }

}
